function h = jcb_plot_spectrum(filename,spectrum,savefigure, fileformat)

if nargin<4
    fileformat='png';
end
if nargin<3
    savefigure=false;
end
if nargin<2
    spectrum='scattering';
end
if nargin<1
    error('not enough input arguments');
end

[pathname filename ext] = fileparts(filename);

%%
if strcmp(spectrum,'scattering')
    spectcol=2;
    ytag='scat';
elseif strcmp(spectrum,'absorption')
    spectcol=3;
    ytag='abs';
elseif strcmp(spectrum,'extinction')
    spectcol=4;
    ytag='ext';
elseif strcmp(spectrum,'all')
    spectcol=[2:4];
    ytag='i';
end

%% load file & extract data
disp(['extracting spectra from file ' filename ext]);
data=load(fullfile(pathname,[filename ext]));
lambda=data(:,1);

%% plot figure
h = figure(26578);
plot(lambda,data(:,spectcol));
title([spectrum ' spectrum for ' strrep(strrep(filename,'_spectra',''),'_','\_') '.fsp']);
xlabel('\lambda /nm');
ylabel(['\sigma_{' ytag '} /\mum^2']);
if length(spectcol)>1
    legend('scattering','absorption','extinction');
    title(['spectra for ' strrep(strrep(filename,'_spectra',''),'_','\_') '.fsp']);
end

if savefigure
    print(['-d' fileformat],fullfile(pathname,[filename '_' spectrum]));
    close(26578);
end

if nargout<1
    clear h
end
end